

$(function(){
	addModuleLinkClickListener();
});

var addModuleLinkClickListener = function(evt) {
    $(".fa-link").click(function(evt) {
        //expand the folder if exists
        var folderId=this.getAttribute("data-folder-id");
        if(folderId){
            var folder=$(folderId);
            if(!folder.hasClass("expand")){
                folder.click();
            }
        }
        $(".active").removeClass("active");
        $(this).addClass("active");
    });

    $(".fa-folder").click(function() {
        //the arrow
        $(this).children().last()
        .toggleClass("fa-angle-left")
        .toggleClass("fa-angle-down");

        $(".expand").removeClass("expand").next().slideToggle();
        $(this).addClass("expand").next().slideToggle(1000);

    })
};
/**
 * 用于打开指定菜单,如openMenu("修改密码")
 *
 */
window.top.openMenu = function(menu,params) {
    if (menu === "首页") {
        document.getElementById("dashboardLinkEL").click();
        return;
    }
    menu=menu.trim();
    $(".fa-link",window.top.document).each(function(link) {
        if (this.textContent.trim() === menu) {
            this.setAttribute("params",params);
            this.click();
            return false;
        }
    });
}

window.top.dashboard = function() {
    window.top.openMenu('首页');
}


var exitSystem = function() {
    if (window.confirm("确认退出?")) {
       window.logout();
    }
}
